package com.cskaoyan.catmall.model.vo.keyword;

import com.cskaoyan.catmall.config.keyword.DateUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 创建日期: 2022/01/07 15:26
 *
 * @author WangZhe
 * 备注:
 */

@NoArgsConstructor
@Data
public class KeywordVo {

    @JsonProperty("id")
    private Integer id;

    @JsonProperty("keyword")
    private String keyword;

    @JsonProperty("url")
    private String url;

    @JsonProperty("isHot")
    private Boolean isHot;

    @JsonProperty("isDefault")
    private Boolean isDefault;

    @JsonProperty("sortOrder")
    private Integer sortOrder;

    @JsonProperty("addTime")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String addTime;

    @JsonProperty("updateTime")
    private String updateTime;

    @JsonProperty("deleted")
    private Boolean deleted;

    public void setIsHot(Integer temp) {
        isHot = temp == 1;
    }

    public void setIsDefault(Integer temp) {
        isDefault = temp == 1;
    }

    public void setDeleted(Integer temp) {
        this.deleted = temp == 1;
    }

    public void setAddTime(Date addTime) {
        this.addTime = DateUtils.formatDate(addTime);
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = DateUtils.formatDate(updateTime);
    }
}
